package cc.wsyw126.java.collection.list;

import java.util.ArrayList;

/**
 * Created by junpeng.yang on 16/8/26.
 */
public class TestSteamForeach {
    public static void main(String[] args) {

        ArrayList<Integer> arrayList = new ArrayList<>();
        for (int i = 0; i < 100000; i++)
            arrayList.add(i);
        long start = System.currentTimeMillis();
        for (int i = 0; i < arrayList.size(); i++) {

        }
        System.out.println("System.currentTimeMillis() - start = " + (System.currentTimeMillis() - start));

        System.out.println("--------------------");
        start = System.currentTimeMillis();
        arrayList.forEach(n -> {});
        System.out.println("System.currentTimeMillis() - start = " + (System.currentTimeMillis() - start));
        System.out.println("--------------");

        start = System.currentTimeMillis();
        for (Integer integer : arrayList) {

        }
        System.out.println("System.currentTimeMillis() - start = " + (System.currentTimeMillis() - start));
    }
}
